<template>
	<view>
		<myhead left="1"></myhead>
		<view class="list" v-for="(item,index) in list" :key="index">
			<view>
				<view>姓名：{{item.bankUserName}}</view>
				<view>银行卡号：{{item.bankNo}}</view>
			</view>
			<view class="scBtn" :data-id="item.id" @tap="deleteBtn">删除</view>
		</view>
		<!-- <view class="list">
			<view>
				<view>姓名：打发士大夫</view>
				<view>银行卡号：ASDFSDFDG2165651ASD65</view>
			</view>
			<view class="scBtn">删除</view>
		</view> -->
		<view class="tjBtn" @tap="tjBtn">添加银行卡</view>
	</view>
</template>

<script>
	const http = require('../../utils/http.js');
	export default {
		data() {
			return {
				list:null
			}
		},
		onShow() {
			uni.showLoading({
			    title: '加载中'
			});
			http.get('/api/user/getMyBank').then(res => {
				if (res.code == 200 && res.result) {
					this.list=res.result
				}
				uni.hideLoading();
			})
		},
		methods: {
			tjBtn:function(){
				uni.navigateTo({
					url:'/pages/user/addBankCard'
				})
			},
			deleteBtn:function(e){
				uni.showLoading({
				    title: '加载中'
				});
				http.get('/api/user/delBank',{bankId:e.currentTarget.dataset.id}).then(res => {
					uni.showToast({
					  title: res.message,
					  icon: 'none',
					  duration:1000
					});
					if (res.code == 200) {
						http.get('/api/user/getMyBank').then(res => {
							if (res.code == 200 && res.result) {
								this.list=res.result
							}
						})
					}
					uni.hideLoading();
				})
			}
		}
	}
</script>

<style>
	page{
		background: #f6f6f6;
	}
	.list{
		background: #FFFFFF;
		padding: 6vw;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		margin-top: 2vw;
	}
	.list>view:nth-child(1)>view:nth-child(2){
		margin-top: 2vw;
		color: #999999;
		font-size: 3.8vw;
	}
	.list .scBtn{
		background: #DD524D;
		color: #FFFFFF;
		font-size: 3.2vw;
		border-radius: 2vw;
		padding: 2.1vw 5vw;
	}
	.tjBtn{
		width: 84%;
		padding: 4vw 0;
		font-size: 3.5vw;
		border-radius: 1.8vw;
		background-image: linear-gradient(45deg, #24EBA9, #10C7B2);
		color: #FFFFFF;
		text-align: center;
		margin: 0 auto;
		margin-top: 10vw;
	}
</style>
